namespace SimpleWebServices.Models
{
    using System.Net.Mail;
    using System.Xml.Serialization;

    [XmlRoot("email")]
    public sealed class Email : ValueObject<Email>
    {
        public Email()
        {
        }

        public Email(string address, string name)
        {
            this.Address = address;
            this.Name = name;
        }

        [XmlAttribute("address")]
        public string Address
        {
            get;
            set;
        }

        [XmlAttribute("key")]
        public string Key
        {
            get;
            set;
        }

        [XmlAttribute("name")]
        public string Name
        {
            get;
            set;
        }

        public MailAddress ToMailAddress()
        {
            return new MailAddress(this.Address, this.Name);
        }
    }
}